#ifndef __SIZEDQUEUE_H__
#define __SIZEDQUEUE_H__

#include <queue>
#include "util/Pool.h"

template <typename T>
class SizedQueue : public std::deque<T, pool_allocator<T> > {
  public:
    NEW_DELETE_OPERATORS_INLINE_H(SizedQueue,NoSuper);
    
    SizedQueue (uint size) {
        maxSize = size;
    };

    virtual ~SizedQueue () {};

    // push puts a new item into the back of the queue
    // in hardware you would loose data if you try to insert into a full queue
    // so here we assert that doesn't happen
    void push (T t) {
        ASSERT(!full());
        std::deque<T,pool_allocator<T> >::push_back(t);
    }

    void pop () {
        std::deque<T,pool_allocator<T> >::pop_front();
    }

    uint slotsAvail () {
        return (maxSize - this->size());
    }

    bool full () {
        return (this->size() >= maxSize);
    }

    void flush () {
        this->clear();
    }

  private:
    uint maxSize;
};

#endif // __SIZEDQUEUE_H__
